import { createStore } from 'vuex';

export const store = createStore({
  state: {
    count: 0
  },
  mutations: {
  //类似 mvc框架的service层参数是state状态管理
    increment(state) {
      state.count++;
    }
  },
  //类似controller
  actions: {
    // 参数是上下文对象
    increment(context) {
    //类似提交service层
      context.commit('increment');
    }
  },
  //类似计算属性
  getters: {
    doubleCount(state) {
      return state.count * 2;
    }
  }
});
